package io.renren.modules.app.dao;

import io.renren.modules.app.entity.ImFriendEntity;
import io.renren.modules.app.entity.ImTagEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-05-23 08:46:57
 */
@Mapper
public interface ImTagDao extends BaseMapper<ImTagEntity> {

    @Select("SELECT ft.id ftId,t.id,t.`name` FROM im_friend_tag ft,im_tag t,tb_user u WHERE ft.tag_id=t.id AND u.user_id=t.user_id AND ft.friend_id=#{userId}")
    List<ImTagEntity> selectFriendList(Long userId);
    @Select("SELECT\n" +
            "\tft.friend_id,f.nickname,u.avatar,u.nickname usernickname,u.username\n" +
            "FROM\n" +
            "\tim_friend_tag ft,\n" +
            "\tim_tag t,\n" +
            "\ttb_user u,\n" +
            "\tim_friend f\n" +
            "WHERE\n" +
            "\tf.friend_id = ft.friend_id\n" +
            "AND f.user_id = t.user_id\n" +
            "AND ft.tag_id = t.id\n" +
            "AND u.user_id = ft.friend_id\n" +
            "AND f.isblack = 0\n" +
            "AND t.id = #{id}")
    List<ImFriendEntity> read(Integer id);
}
